﻿using System;
using System.Collections.Generic;
using System.Speech.Synthesis;
using System.Windows;
using Entity;
using IntelligentPharmacy;
using IntelligentPharmacy.publicclass;
using IntelligentPharmacy.httprequest;
using ConsumablesCabinet;
using SmartForcer.Enum;

namespace SmartRoom
{
    /// <summary>
    /// MessageWindow.xaml 的交互逻辑
    /// </summary>
    public partial class CheckLisenseWindow : Window
    {
        requestService rqst = new requestService();
 
        public CheckLisenseWindow()
        {
            InitializeComponent();
        }

        private void btn_Exit_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void Window_Loaded_1(object sender, RoutedEventArgs e)
        {
            txt_DeviceMac.Text = DeviceInfo.GetMacAddress();//GetCpuID();
        }

        private void btn_Submit_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(txt_DeviceName.Text))
            {
                MessageBox.Show("请输入设备名称!");
                txt_DeviceName.Focus();
                return;
            }
            if (rqst.InsertDeviceInfo(txt_DeviceMac.Text, txt_DeviceName.Text))
            {
                ReadAppConfig.writeWarehouseName(txt_DeviceName.Text);
                Global.MessageWindow.ShowDialog("注册成功！",MessageButton.Close,MessageStyle.Success);
                this.Close();
            }
            else
            {
                Global.MessageWindow.ShowDialog("注册失败，请检查网络重新提交或联系管理员！", MessageButton.Close, MessageStyle.Error);
                this.Close();
            }
        }
    }
}
